# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=man-pages
pkgver=5.08
_posixver=2013-a
pkgrel=0
pkgdesc="Linux man pages"
url="https://www.kernel.org/doc/man-pages/"
arch="noarch"
license="GPL-2.0-or-later"
options="!strip !check"
source="https://cdn.kernel.org/pub/linux/docs/man-pages/man-pages-$pkgver.tar.xz
	https://cdn.kernel.org/pub/linux/docs/man-pages/man-pages-posix/man-pages-posix-$_posixver.tar.xz
	"

build() {
	mkdir man0
	for sect in 0 1 3; do
		sed -i "/^\.so /s/man${sect}p/man$sect/" \
			"$srcdir"/$pkgname-posix-$_posixver/man${sect}p/*
		mv "$srcdir"/$pkgname-posix-$_posixver/man${sect}p/* \
			"$srcdir"/$pkgname-$pkgver/man$sect/
	done
}

package() {
	make prefix="$pkgdir"/usr install
	find "$pkgdir"/usr/share/man -name "*.[0-9]" -o -name "*.[0-9]p" \
		| xargs gzip -9

	# provided by libiconv-doc
	rm -f "$pkgdir"/usr/share/man/man3/iconv*

	# provided by mandoc
	rm -f "$pkgdir"/usr/share/man/man7/man* \
		"$pkgdir"/usr/share/man/man7/mdoc*

	# provided by tzdata
	rm -f "$pkgdir"/usr/share/man/man5/tzfile* \
		"$pkgdir"/usr/share/man/man8/tzselect* \
		"$pkgdir"/usr/share/man/man8/zic* \
		"$pkgdir"/usr/share/man/man8/zdump*

	# provided by libbsd
	rm -f "$pkgdir"/usr/share/man/man3/explicit_bzero*
}

sha512sums="fbd54c96c3ef1272f856a27d2258fefd3934d9f6ef60c243a824377769c4784b65aba54d680bb382371b0ce35fd4d065b17980cb535118e7986844f19afd7932  man-pages-5.08.tar.xz
e6ec8eb57269fadf368aeaac31b5a98b9c71723d4d5cc189f9c4642d6e865c88e44f77481dccbdb72e31526488eb531f624d455016361687a834ccfcac19fa14  man-pages-posix-2013-a.tar.xz"
